﻿using PLCS.Application.Contracts.OrderApp.Dtos;
using PLCS.Application.Contracts.TaskApp.Dtos;
using PLCS.Client.IService.OrderTask;
using PLCS.Domain.Shared.Tasks;

using System.Threading.Tasks;

using Volo.Abp.Application.Dtos;

namespace PLCS.Client.Service.OrderTask;

public class OrderService : BaseService<OrderDto, OrderEditDto>, IOrderService
{
    public async Task<PagedResultDto<OrderDto>> GetListBySearchAsync(int skipCount, int maxResultCount, string? orderNo)
    {
        var route = $"order/bySearch?SkipCount={skipCount}&MaxResultCount={maxResultCount}";
        if (!string.IsNullOrEmpty(orderNo))
            route += $"&orderNo={orderNo}";

        RequestParam requestParam = new(method: Method.Get, route: route);
        var apiRes = await restClient.ExecuteAsync<PagedResultDto<OrderDto>>(requestParam);
        if (apiRes.Status)
            return apiRes.Data;
        else
            return new PagedResultDto<OrderDto>();
    }
}